package com.zhf.rabbitmq.utils;

import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;

/**
 * @author: 曾鸿发
 * @create: 2022-01-08 18:09
 * @description：
 **/
public class RabbitUtil {

    private static ConnectionFactory connectionFactory = new ConnectionFactory();

    static {
        connectionFactory.setHost("192.168.199.128");
        connectionFactory.setPort(5672);
        connectionFactory.setVirtualHost("/baiqi_1127");
        connectionFactory.setUsername("zhf");
        connectionFactory.setPassword("123456");
    }

    public static Connection getConnection() {
        Connection connection = null;
        try {
            connection = connectionFactory.newConnection();
            return connection;
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
}
